from django.contrib.auth.decorators import login_required
from django.utils.decorators import classonlymethod


class LoginRequiredMixin(object):
    '''
        装饰登录权限问题。只要继承这个实体类就是需要有登录权限才能访问
    '''

    @classonlymethod
    def as_view(cls, **initkwargs):
        view = super(LoginRequiredMixin, cls).as_view(**initkwargs)
        return login_required(view)
